define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'pro/feedback/index',
                    add_url: 'pro/feedback/add',
                    edit_url: 'pro/feedback/edit',
                    del_url: 'pro/feedback/del',
                    multi_url: 'pro/feedback/multi',
                    table: 'gzns_user_feed_back',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'feedback.id',
                search:false,
                showColumns: false,
                showToggle: false,
                showExport: false,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'user.nick_name',align:"left", operate: 'LIKE',title: __('微信昵称'),formatter: function (value, row, index) {
                        //     if(row.user.nick_name){
                        //         var image = '<a href="'+row.user.avatar+'" target="_blank"><img class="img-sm img-center" src="'+row.user.avatar+'"></a>'
                        //         return image + " "+row.user.nick_name;
                        //     }else{
                        //         return "未绑定"
                        //     }
                        // }},
                        // {field: 'company_name',align:"left", operate: 'LIKE',title: __('企业信息'),formatter: function (value, row, index) {
                        //     return row.real_name+"【"+row.company_name+"】"+"【"+row.phone+"】"
                        // }},
                        {field: 'real_name',operate: 'LIKE', title: __('联系人')},
                        {field: 'phone',operate: 'LIKE', title: __('电话')},
                        {field: 'detail',align:"left",operate:false, title: __('反馈内容')},
                        {field: 'is_read', title: __('回复状态'), searchList: {"0":__('未回复'),"1":__('已回复')}, formatter: Table.api.formatter.normal},
                        {field: 'create_time', title: __('Create_time'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
